import { defineConfig } from "@rsbuild/core";
import * as rspack from "@rspack/core";
import { pluginReact } from "@rsbuild/plugin-react";
import { pluginLess } from "@rsbuild/plugin-less";
import path from "path";
import { myEnvironmentPlugin } from "./plugins/myEnvironmentPlugin";
import { pluginUmd } from "@rsbuild/plugin-umd";

console.log("获取assetPrefix", process.env.PUBLIC_URL);

export default defineConfig({
  html: {
    inject: false,
    title: "元汽泉",
    template: "./index.html",
  },
  resolve:{
    alias:{
      '@low-code':path.resolve(__dirname,'src','lowCode')
    }
  },
  output: {
    assetPrefix: process.env.PUBLIC_URL || "",
    minify: false,
    injectStyles: true,
    filenameHash: false,
    externals: {
      // 'react-router-dom':'react-router-dom',
      "react-dom": "react-dom",
      react: "react",
      ahooks: "ahooks",
      axios: "axios",
      // "@ant-design/icons": "@ant-design/icons",
      antd: "antd",
    },
  },

  server: {
    port: 8088,
  },

  plugins: [
    myEnvironmentPlugin(),
    pluginReact(),
    pluginLess({
      lessLoaderOptions: {
        lessOptions: {
          javascriptEnabled: true,
          paths: [path.join(__dirname, "node_modules")],
        },
        implementation: require.resolve("less"),
      },
    }),
    //   @ts-ignore
    pluginUmd({}),
  ],
});
